﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AlphaSolutionsGP.Demo_classes
{
    class ModuleDemo
    {
        Module m1;
        Module m2;
        private string passorfail;
        private int _pass;
        private int _fail;

        public ModuleDemo()
        {
            if ((testModuleNoArgConstructor()) == false)
            {
                _fail++;
            }
            else
            {
                _pass++;
            }
            if ((testModuleArgConstructor()) == false)
            {
                _fail++;
            }
            else
            {
                _pass++;
            }
            if ((testCreateModule()) == false)
            {
                _fail++;
            }
            else
            {
                _pass++;
            }
            if ((testAmmendModule()) == false)
            {
                _fail++;
            }
            else
            {
                _pass++;
            }
            if ((testDeleteModule()) == false)
            {
                _fail++;
            }
            else
            {
                _pass++;
            }
        }

        bool testModuleArgConstructor()
        {
            bool success = false;
            try
            {
                m2 = new Module("F1002", "COMP01", "Test", "Testing","this is a test", 1,"99100012",1);
                success = true;
            }
            catch (Exception e)
            {
                success = false;
            }
            return success;
        }
        bool testModuleNoArgConstructor()
        {
            bool success = false;
            try
            {
                m2 = new Module();
                success = true;
            }
            catch (Exception e)
            {
                success = false;
            }
            return success;
        }
        bool testCreateModule()
        {
            bool success = false;
            try
            {
                m2.createModule();
                success = true;
            }
            catch (Exception e)
            {
                success = false;
            }
            return success;
        }
        bool testAmmendModule()
        {
            bool success = false;
            try
            {

                m2.ammendModule("F1002");
                success = true;
            }
            catch (Exception e)
            {
                success = false;
            }
            return success;
        }
        bool testDeleteModule()
        {
            bool success = false;
            try
            {

                m2.deleteModule();
                success = true;
            }
            catch (Exception e)
            {
                success = false;
            }
            return success;
        }
        bool testGetters()
        {
            bool success = false;
            try
            {

                m1.Credits = 1;
                m1.NumberOfAssignments = 3;
                success = true;
            }
            catch (Exception e)
            {
                success = false;
            }
            return success;
        }
        public int Fail
        {
            get { return _fail; }
            set { _fail = value; }
        }

        public int Pass
        {
            get { return _pass; }
            set { _pass = value; }
        }
    }


}
